<?php
error_reporting(0);
/*
$fp = fopen('./test.log','a+');
fwrite($fp,serialize($_GET));
fwrite($fp,'--------------');
fwrite($fp,serialize($_POST));
fclose($fp);
*/
//require_once('geoip.php');
// Ahost Aport Apro Alevel
//proxyserver.php?toauth=7a91ca26e1603f4b898e722dbdfab743;
$toauth = '7a91ca26e1603f4b898e722dbdfab743';
if($_GET['toauth'] == $toauth){
	$ProxyArr = &$_POST;
	if(count($ProxyArr['Ahost'])>0){
		//$file = sprintf('%s/proxy/%s/%s.log',dirname(__FILE__),date('Y-m'),date("Y-m-d"));
		//$dir = dirname($file);
		//if(!file_exists($dir)){
		//	mkdir($dir);
		//}
		//$fp = fopen($file,'a+');
		$strip = '';
		//$gi = geoip_open('GeoIP.dat',GEOIP_STANDARD);
		$redis = new Redis();
		$redis->connect('127.0.0.1', 6379);
		$redis->select(1);
		foreach($ProxyArr['Ahost'] as $k =>$v){
			$ip = sprintf('%s:%s@%s',$v,$ProxyArr['Aport'][$k],$ProxyArr['Apro'][$k]);
			$redis->lpush('proxy',$ip);
			//$strip .= "$v:{$ProxyArr['Aport'][$k]} #{$ProxyArr['Apro'][$k]} {$ProxyArr['Alevel'][$k]}\n";
			//$country_code = geoip_country_code_by_addr($gi,$v);
			//$strip .= sprintf("%s|%s|%s|%s|%s|0|%s|%s \n",$v,$ProxyArr['Aport'][$k],$ProxyArr['Apro'][$k],$ProxyArr['Alevel'][$k],$country_code,date("Y-m-d H:i:s"),$country_code);
			//'31.220.96.126|1212|HTTP|3|US|0|2014-4-7 14:32:6 |US ';
		}
		//fwrite($fp,$strip);
		//geoip_close($gi);
		//fclose($fp);
	}
}
?>